

package cn.edu.nsmc.modules.sys.dao;

import cn.edu.nsmc.modules.sys.entity.SysUserEntity;
import cn.edu.nsmc.modules.sys.entity.excel.SysUserEntityExcel;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 系统用户
 *
 *
 */
@Mapper
public interface SysUserDao extends BaseMapper<SysUserEntity> {

	/**
	 * 查询用户的所有权限
	 * @param userId  用户ID
	 */
	List<String> queryAllPerms(Long userId);

	/**
	 * 查询用户的所有菜单ID
	 */
	List<Long> queryAllMenuId(Long userId);

	/**
	 * 根据用户名，查询系统用户
	 */
	SysUserEntity queryByUserName(String username);

    Integer importRepairman(Long userId, List<SysUserEntityExcel> list);

	List<SysUserEntityExcel> exportRepairman(SysUserEntity sysUserEntity);

	Integer attCntAll(Date startTime, Date endTime);
	Integer attCntRecently(Integer spanType);

	Integer repCntAll(Date startTime, Date endTime);

	Integer repCntRecently(Integer spanType);

	@Select("select name from sys_user where user_id=#{repairmanId}")
    String getNameById(Long repairmanId);

	@Select("select * from sys_user where user_id=#{auditorId}")
	SysUserEntity getOneById(Integer auditorId);

	@MapKey("")
	List<Map<String,Object>> nameList(String name);

	@Select("select type from sys_user where user_id=#{userId}")
    Integer getUserTypeByUserId(Long userId);

	@Update("update sys_user set password=#{newPassword},salt=#{salt} where user_id=#{userId}")
	Integer resetPassword(Long userId, String salt, String newPassword);
}
